﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Soundteller.Audio.Model;
using Soundteller.AudioVisual.Model;
using Soundteller.Common.Tests;
using Soundteller.Visual.Model;
using System.Collections.Generic;

namespace Soundteller.AudioVisual.Tests.Unit.Services.PadToucherSpecifications
{
    [TestClass]
    public class WhenTouchGivenArgumentsIsNull : PadToucherTestBase
    {
        protected override PadTouchArguments Arguments
        {
            get { return (PadTouchArguments)null; }
        }

        protected override void Act()
        {
            ExpectException(() => base.Act());
        }

        [TestMethod]
        public void ThenAnArgumentNullExceptionShouldBeThrown()
        {
            Exception.VerifyArgumentNullException("arguments");
        }
    }

    [TestClass]
    public class WhenTouchGivenNoPadsTouched : PadToucherTestBase
    {
        protected override PadTouchArguments Arguments
        {
            get { return new PadTouchArguments(); }
        }

        [TestMethod]
        public void ThenNoSoundsShouldBeBuffered()
        {
            SoundBufferRepository.Verify(r => r.Push(It.IsAny<Sound>()), Times.Never());
        }
    }

    [TestClass]
    public class WhenTouchGivenOnePadTouched : PadToucherTestBase
    {
        private Pad _touchedPad;

        protected override PadTouchArguments Arguments
        {
            get { return new PadTouchArguments(); }
        }

        protected override void Arrange()
        {
            base.Arrange();

            _touchedPad = new Pad { Graphic = new GeneratedGraphic(), Sound = new Sound() };
            PadRepository.Setup(r => r.GetByGraphicCategory(It.IsAny<string>())).Returns(new List<Pad> { _touchedPad });
        }

        [TestMethod]
        public void ThenOneSoundShouldBeBuffered()
        {
            SoundBufferRepository.Verify(r => r.Push(_touchedPad.Sound), Times.Once());
        }
    }
}